﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KCBF.Modules.AI
{
    static class Blackboard
    {
        static readonly Dictionary<Guid,Dictionary<string, object>> _properties = new Dictionary<Guid, Dictionary<string, object>>();
        static readonly Dictionary<string, object> _globals = new Dictionary<string, object>(); 


        static Blackboard()
        {
            _globals.Add("next_move",new Queue<D3.Point>());
        }

        public static object GetGlobal(string key)
        {
            if (!_globals.ContainsKey(key)) return null;
            return _globals[key];
        }


        public static void SetGlobal(string key, object value)
        {
            if (_globals.ContainsKey(key)) _globals[key] = value;
            else _globals.Add(key, value);
        }


        public static object GetProperty(Guid guid, string key)
        {
            if (!_properties.ContainsKey(guid)) _properties.Add(guid,new Dictionary<string, object>());
            if (!_properties[guid].ContainsKey(key)) return null;
            else return _properties[guid][key];
        }

        public static void SetProperty(Guid guid, string key, object value)
        {
            if (!_properties.ContainsKey(guid)) _properties.Add(guid, new Dictionary<string, object>());
            if (_properties[guid].ContainsKey(key)) _properties[guid][key] = value;
            else _properties[guid].Add(key,value);
        }


    }
}
